<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>Cubes Model</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="">

    <link href="{{url_for('static', filename='css/bootstrap.min.css')}}" rel="stylesheet">
    <style type="text/css">
      body {
        padding-top: 60px;
        padding-bottom: 40px;
      }
      .sidebar-nav {
        padding: 9px 0;
      }
    </style>
    <link href="{{url_for('static', filename='css/bootstrap-responsive.min.css')}}" rel="stylesheet">

    <!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
    <!--[if lt IE 9]>
      <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->

    <!-- Fav and touch icons -->
  </head>

  <body>

    <div class="navbar navbar-inverse navbar-fixed-top">
      <div class="navbar-inner">
        <div class="container-fluid">
          <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </a>
          <a class="brand" href="#">Cubes Model Browser</a>
        </div>
      </div>
    </div>

    <div class="container-fluid">
      <div class="row-fluid">
        <div class="span3">
          <div class="well sidebar-nav">
            <ul class="nav nav-list">
              <li class="nav-header">Dimensions</li>
              {% for dim in dimensions %}
              <li {% if dimension and dim.name == dimension.name %}class="active"{%endif%}>
                <a href="{{dim.name}}">{{dim.label or dim.name}}</a>
                </li>
              {% endfor %}
            </ul>
          </div><!--/.well -->
        </div><!--/span-->

        <div class="span9">
            {% if dimension %}
            <h1>{{dimension.label or dimension.name}}</h1>
            <dl class="dl-horizontal">
                  <dt>Name</dt><dd>{{dimension.name}}</dd>
                  <dt>Label</dt><dd>{%if dimension.label %}{{dimension.label}}{%else%}
                      <span class="label label-warning">missing</span>{%endif%}</dd>
                  <dt>Description</dt><dd>{%if dimension.description %}{{dimension.description}}{%else%}
                      <span class="label">no description</span>{%endif%}</dd>
                  <dt># of levels</dt><dd>{{dimension.levels|length}}
                  {%if dimension.is_flat %}<span class="label">is flat</span>{%endif%}
                  {%if not dimension.has_details %}<span class="label">no details</span>{%endif%}
                  </dd>
            </dl>
            <h2>Hierarchies</h2>
            <ul>
            {% for hierarchy in dimension.hierarchies %}
            {{hierarchy.label or hierarchy.name}}:
            
                {% for level in hierarchy.levels %}
                <a href="#level-{{level.name}}">{{level.label or level.name}}</a>
                {% if not loop.last %} : {% endif %}
                {% endfor %}
            {% endfor %}
            </ul>
            <h2>Levels</h2>
            {% for level in dimension.levels %}
            <h4><a id="level-{{level.name}}">{{level.label or level.name}}</a></h4>
            <dl class="dl-horizontal">
                  <dt>Name</dt><dd>{{level.name}}</dd>
                  <dt>Label</dt><dd>{%if level.label %}{{level.label}}{%else%}
                      <span class="label label-warning">missing</span>{%endif%}</dd>
                  <dt>Description</dt><dd>{%if level.description %}{{level.description}}{%else%}
                      <span class="label">no description</span>{%endif%}</dd>
                  <dt># of attributes</dt><dd>{{level.attributes|length}}
                  {%if not level.has_details %}<span class="label">no details</span>{%endif%}
                  </dd>
            </dl>
            <table class="table table-bordered">
                <tr>
                    <th>Name</th>
                    <th>Label</th>
                    <th>Reference</th>
                    <th>Locales</th>
                    <th>Description</th>
                </tr>
                {% for attr in level.attributes %}
                <tr>
                    <td>{{attr.name}}</td>
                    <td>{%if attr.label %}{{attr.label}}{%else%}
                      <span class="label
                           label-warning">missing</span>{%endif%}</td>

                   <td>
                       Logical: <code>{{attr.ref()}}</code> <br />
                       {% set logical = attr.ref() %}
                       {% set physical = mapping[logical] %}
                       Column: <code>{{physical.column}}</code><br />
                       Table: <code>{{physical.table}}</code><br />
                       Schema: {% if physical.schema %}<code>{{physical.schema}}</code>
                           {% else %}<small>default schema</small>{% endif %}
                       </code>
                       {% if physical.extract %}
                       <br />Extract: <code>{{physical.extract}}</code>
                       {% endif %}
                   </td>

                    <td>{%if attr.locales %}{{attr.locales|join(", ")}}{%else%}
                      <span class="label
                           label">not localized</span>{%endif%}</td>
                    <td>{%if attr.description %}{{attr.description}}{%else%}
                      <span class="label">no description</span>{%endif%}</td>
                </tr>
                {% endfor %}
            </table>
            {% endfor %}
            {% endif %}
        </div><!--/span-->
      </div><!--/row-->

      <hr>

      <footer>
      <p>Powered by <a href="http://packages.python.org/cubes/">Cubes</a>.</p>
      </footer>

    </div><!--/.fluid-container-->

    <script src="{{url_for('static', filename='js/bootstrap.min.js')}}"></script>

  </body>
</html>

